<?php

namespace app\api\controller\product;
use app\common\controller\BaseController;
use app\common\service\product\ShopProductService;
use app\common\validate\product\ShopProductValidate;
use hg\apidoc\annotation as Apidoc;
/**
 * @Apidoc\Title("商品管理")
 * @Apidoc\Group("product")
 * @Apidoc\Sort("250")
 */
class ShopProduct extends BaseController
{
    /**
    * @Apidoc\Title("商品管理列表")
    * @Apidoc\Query(ref="pagingQuery")
    * @Apidoc\Query(ref="sortQuery")
    * @Apidoc\Query(ref="searchQuery")
    * @Apidoc\Query(ref="dateQuery")
    * @Apidoc\Returned(ref="expsReturn")
    * @Apidoc\Returned(ref="pagingReturn")
    * @Apidoc\Returned("list", type="array", desc="商品管理列表", children={
    *   @Apidoc\Returned(ref="app\common\model\ShopProductModel", field="id,title,content,is_disable,create_time,update_time,store_platform_id,merchant_id,merchant_shop_id,setting_refund_id,shop_product_type_id,status,money,remark,b_is_delivery,b_delivery_price,b_coupon_url,b_coupon_price,c_sort_type,c_pay_num,c_start_price,c_end_price,c_region_id,c_order_remark,c_subject,d_enter_type,e_revoke_time,f_auth_type,f_reward_price,h_pay_time,h_pay_type,sort,order_num,f_increment_num,f_increment_price,d_comment_num,d_comment_price,b_product_num,b_product_price")
    * })
    */
    public function list()
    {
        $param = $this->params([
            'id/d'=>0,
            'setting_store_type_id/d' => null,
            'type/d'=>1,//查询类型：1、首页 2、今日爆款商品 3、平台补贴商品
            'keyword/s'=>null
        ]);
        $data = ShopProductService::getSubsidiesOrder($param, $this->page(), $this->limit(), $this->order());
        return success($data);
    }
    /**
     * @Apidoc\Title("商品管理信息")
     * @Apidoc\Query(ref="app\common\model\ShopProductModel", field="id")
     * @Apidoc\Returned(ref="app\common\model\ShopProductModel")
     */
    public function info()
    {
        $param = $this->params(['id/d' => '']);
        validate(ShopProductValidate::class)->scene('info')->check($param);
        $data = ShopProductService::getSubsidiesInfo($param['id']);
        return success($data);
    }
}
